package com.cwnu.mapper;

import com.cwnu.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    @Select("select * from user where username=#{username};")
    User findByUserName(String username);

    @Insert("insert into user(username, password, age, school, role) values (#{username}, #{password}, #{age}, #{school}, 0);")
    void add(String username,  String password, Integer age, String school);

    @Update("update user set password=#{password} where id=#{id} and role = 0;")
    void updatePassWord(String password, Integer id);


    @Update("update user set age=#{age}, school=#{school} where id=#{id} and role = 0;")
    void update(User user);

    @Delete("delete from user where id=#{userId} and role = 0;")
    void deleteUser(Integer userId);
}
